<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  
</body>
</html>
<script src="./lodash.js"></script>
<script>
/* 
   function fn(date1, date2) {
     // code in here ...
   }
   
   // console.log(fn(时间节点1， 时间节点2)) 
   // 两个时间节点之间相差 3 天 18 个小时 55 分钟 12 秒

*/

function fn(startDate, endDate) {
  var diffMS = Math.abs(endDate - startDate);
  var days = Math.floor(diffMS / (1000 * 60 * 60 * 24));
  var hours =  Math.floor(diffMS % (1000 * 60 * 60 * 24) / (1000 * 60 * 60));
  var minutes = Math.floor(diffMS % (1000 * 60 * 60) / (1000 * 60));
  console.log(`${days} 天 ${hours} 个小时 ${minutes} 分钟`);
}

var today = new Date();

// 注：month 从 0 开始
var olympicBK = new Date(2008, 7, 8, 20, 8, 8);

fn(today, olympicBK);
</script>